﻿@model blacksoft.Models.OrdenCompra

@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_LayoutCompras.cshtml";
}

@if (TempData["create_failure"] != null)
{
    <div class="error grid_12">
        <h3>@TempData["create_failure"].</h3>
        <a class="hide_btn" href="#"></a>
    </div>
}


<div class="block big">
    <div class="titlebar">
        <h3>Nueva Orden de Compra</h3>
    </div>
    <div class="block_cont">
        <form class="form" action="" method="GET">
            <input type="hidden" name="accion" value="seleccionar" />
            <div class="form-group">
                <label>Proveedor:</label>
                <div class="col-md-10">
                    @Html.DropDownList("IDPersona_Proveedor", null, (string)ViewBag.proveedor, new { @class = "select"})
                    @Html.ValidationMessageFor(model => model.IDPersona_Proveedor)
                </div>
            </div>
            <br />
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" class="submit" value="Seleccionar" />
            </div>
        </form>

        <hr />

        <h4>Producto</h4>
        <form class="form" action="" method="GET">
            <input type="hidden" name="accion" value="buscar" />
            <div class="form_row">
                <label>Nombre:</label>
                <input class="input" type="text" style="width: 290px;" name="searchNombre" id="searchNombre" />
            </div>
            @*<div class="form_row">
                    <label>Codigo:</label>
                    <input class="input" type="text" style="width: 290px;" name="searchCodigo" id="searchCodigo" />
                </div>*@
            <div class="form-row">
                <input type="submit" class="submit" value="Buscar" />
            </div>
        </form>
        <br />
        <fieldset style="width: 280px; padding:5px; border:2px solid">
            <legend>
                <label>@ViewBag.infoProductoNombre</label>
            </legend>
            <dl class="dl-horizontal">
                <dt>
                    Precio
                </dt>
                <dd>
                    @ViewBag.infoProductoPrecio
                </dd>
                <dt>
                    Unidad
                </dt>
                <dd>
                    @ViewBag.infoProductoUnidad
                </dd>
            </dl>
        </fieldset>


        <form class="form" action="" method="GET">
            <input type="hidden" name="accion" value="agregar" />
            <div class="form-row">
                <label>Cantidad:</label>
                <input class="input" type="number" name="scantidad" id="scantidad" pattern="^([1-9]|[1-9][0-9]|[1-9][0-9][0-9])$" required />
            </div>
            <br />
            <div class="form-row">
                <input type="submit" class="submit" value="Agregar" />
            </div>
        </form>
        <br />
        <hr />
        @*<div>
            @Html.DisplayFor(model => model)
        </div>*@
        <div class="table">
            <table>
                <thead>
                    <tr>
                        <th>Producto</th>
                        <th>Precio</th>
                        <th>Cantidad</th>
                        <th>Subtotal</th>
                    </tr>
                </thead>
                @{for (int i = 0; i < Enumerable.Count(ViewBag.tabla); i++)
                    {
                        <tr>
                            <td> @ViewBag.Tabla[i][0] </td>
                            <td> @ViewBag.Tabla[i][1] </td>
                            <td> @ViewBag.Tabla[i][2] </td>
                            <td> @ViewBag.Tabla[i][3] </td>
                        </tr>
                    }
                }
            </table>
        </div>



        @using (Html.BeginForm())
        {
            @Html.AntiForgeryToken()

            <div class="form-horizontal">

                <br />
                <div class="form-group">
                    <input type="submit" value="Registrar" class="btn btn-default" />
                    <br />
                    @Html.ActionLink("Regresar al listado", "Index")
                </div>
            </div>
        }
    </div>
</div>



  
